<?php
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;

?>

<style>
    .add_user li input[type='password'] {
        width: 240px;
        height: 32px;
        line-height: 32px;
    }
    .itemList .item-name{width: 70px;}
    input[type="text"]{padding-left: 10px;}
    input[type="reset"] {background-color:#999;}
    .myclass{
        top: 12px;
        left:-250px;
    }
    .myclass .n-icon{
        display: none !important;
    }
    .form_position{
        position: relative;
        top:40px;
        margin: 0 80px;
    }

    .form-group{
        padding-bottom:22px;
        margin-bottom: 5px;
    }
    .tab_position{
        position: relative;
        top:10px;
        left: 80px;
    }
</style>

<div class="container mt10 form_position">
    <?php $form = ActiveForm::begin(['id'=>'myform','options'=>['name'=>'register']]);?>
    <ul class="add_user">
        <li class="itemList clearfix form-group">
            <label class="item-name">原密码</label>
            <div class="item-txt">
                <?= Html::activePasswordInput($model, 'password',['placeholder' => ' 输入原密码']) ?>
                <span class="red">*</span>
            </div>
            <span class="msg-box n-bottom myclass" for="sysuser-password">
                <?php
                if (Yii::$app->session->hasFlash('passError')) {
                    echo '<span role="alert" class="msg-wrap n-error"><span class="n-icon"></span><span class="n-msg">原密码错误</span></span>';
                }
                ?>
            </span>
        </li>
        <li class="itemList clearfix form-group">
            <label class="item-name">新密码</label>
            <div class="item-txt">
                <?= Html::activePasswordInput($model, 'newPassword',['placeholder' => ' 输入新密码' ])?>
                <span class="red">*</span>
            </div>
            <span class="msg-box n-bottom myclass" for="sysuser-newpassword"></span>
        </li>
        <li class="itemList clearfix form-group">
            <label class="item-name">密码确认</label>
            <div class="item-txt">
                <?= Html::activePasswordInput($model, 'oldNewPassword',['placeholder' => '']) ?>
                <span class="red">*</span>
            </div>
            <span class="msg-box n-bottom myclass" for="sysuser-oldnewpassword"></span>
        </li>
    </ul>
    <div  class="tab_position" >
        <span class="btnBg" style="width: 92px; height: 32px;line-height: 32px;">
			  <input type="submit" value="确定" style="display: inline-block; width: 100%; background: 0; border: 0 ;padding: 0" /></span>
		  <span class="btnBg bg_rest ml20" style="width: 92px; height: 32px;line-height: 32px;">
			 <input type="reset" value="取消"  class="rest" style="display: inline-block; width: 100%; background: 0; border: 0;padding: 0"/></span>
    </div>
    <?php ActiveForm::end();?>
</div>

<?php $this->beginBlock('js_index') ?>

$('form[name="register"]').validator({
    focusCleanup: true,
    stopOnError:false,
    //debug: true,
    timely: 2,
    //自定义规则（PS：建议尽量在全局配置中定义规则，统一管理）
    rules: {
    length:[/^\S{6,20}$/, '请填写6到20个字符']
    },
    msgClass: "n-bottom myclass",
    fields: {
    '#sysuser-password':{
            rule:"required;length;match(SysUser[Password])",
            msg:{
            required: "原密码不能为空!",
            match:'原密码错误请重新输入',
            }
    },
    '#sysuser-newpassword':{
            rule:"required;length;",
            msg:{
            required: "密码不能为空!",
            }
    },
    '#sysuser-oldnewpassword':{
      rule:"required;length;match(SysUser[newPassword]);",
      msg:{
        required: "确认密码不能为空!",
        match:'两次密码输入不一致',
      }
    },
    }
});


$('input[type="reset"]').click(function(){
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
})
<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['js_index'], $this::POS_END); ?>



